package puzzle.slilin2.loader;

import puzzle.common.loader.AbstractLoader;
import puzzle.common.loader.Preprocessor;
import puzzle.common.point.Pnt;
import puzzle.slilin2.data.SlilinPntHelper;
import puzzle.slilin2.data.SlilinBoard;

public class SlilinLoader extends AbstractLoader<SlilinBoard> {
	@Override
	protected SlilinBoard process(Preprocessor pp) {
		SlilinBoard b = new SlilinBoard(pp.getWidth(), pp.getHeight());
		int y = 0;
		for (String[] line : pp.getLines()) {
			for (int x = 0; x < line.length; x++) {
				int number = line[x].charAt(0) - '0';
				if (number >= 0 && number <= 3) {
					Pnt p = SlilinPntHelper.getPhysicalPoint(new Pnt(x, y));
					b.setNumber(p, number);
				}
			}
			y++;
		}

		return b;
	}
}
